<template>
  <!-- 客服管理 列表 -->
  <div class="">
    <!-- 客服统计 -->
    <div class="kefu-tingji-box flex">
      <div class="kefu-num-box">
        <div style="color: #6C5DD3;font-size: 24px;font-weight: bold;">
          {{ total||0 }}
        </div>
        <div style="color: #666666;margin: 5px 0;">已设置客服</div>
        <span style="display: inline-block; color: #6C5DD3;background-color: #6C5DD333;padding: 0 10px;border-radius: 5px;" v-if="tenantInfo&&tenantInfo.groups.includes('5495')">
          已开通客服包月
        </span>
        <div v-else>
          <el-button size="mini" type="primary" @click="goYDSC">去开通</el-button>
        </div>
        <div v-if="tenantInfo&&tenantInfo.groups.includes('5495')" style="color: #6C5DD3;margin-top: 10px;">
          客服包月到期时间:{{ baoyueTime }}
        </div>
        <div style="color: #FA6400;margin-top: 10px;">
          提示: 开通包月后线上客服不限量，到期后按照未包月扣除
        </div>
      </div>
      <div class="zixun-box">
        <subtit title="咨询人数统计">
          <div class="select flex">
            <div class="day3" @click="tongjiData.days=30;getZixun()" :class="{active:tongjiData.days===30}">近30天</div>
            <div class="day2" @click="tongjiData.days=7;getZixun()" :class="{active:tongjiData.days===7}">近7天</div>
            <div class="day1" @click="tongjiData.days='';getZixun()" :class="{active:tongjiData.days===''}">今天</div>
          </div>
        </subtit>
        <div class="cont_box flex">
          <div class="tongji-item flex">
            <img src="../../../assets/images/fabu.png" alt="">
            <div class="rg">
              <div class="tit">买号咨询</div>
              <div class="num">
                <count-to :start-val="0" :end-val="tongjiData.buyZixun" :duration="1000" class="card-panel-num" />
              </div>
            </div>
          </div>
          <div class="tongji-item bjsl flex">
            <img src="../../../assets/images/yibaojia.png" alt="">
            <div class="rg">
              <div class="tit">卖号咨询</div>
              <div class="num">
                <count-to :start-val="0" :end-val="tongjiData.sellZixun" :duration="1000" class="card-panel-num" />
              </div>
            </div>
          </div>
          <div class="tongji-item wbjsl flex">
            <img src="../../../assets/images/weibaojia.png" alt="">
            <div class="rg">
              <div class="tit">商家咨询</div>
              <div class="num">
                <count-to :start-val="0" :end-val="tongjiData.merchantZixun" :duration="1000" class="card-panel-num" />
              </div>
            </div>
          </div>
          <div class="tongji-item zbsl flex">
            <img src="../../../assets/images/zhongbiao.png" alt="">
            <div class="rg">
              <div class="tit">其他咨询</div>
              <div class="num">
                <count-to :start-val="0" :end-val="tongjiData.otherZixun" :duration="1000" class="card-panel-num" />
              </div>
            </div>
          </div>
        </div>

      </div>
    </div>
    <div class="list-box">
      <div style="margin-bottom: 5px;">
        <subtit title="在线客服"></subtit>
      </div>
      <el-form class="search-form-new" :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80">
        <el-form-item label="店铺" prop="tenantId" v-hasPermi="['searchTenantID']">
          <el-select v-model="queryParams.tenantId" placeholder="请选择店铺" clearable filterable size="small">
            <el-option v-for="dict in tenantList" :key="dict.tenantId" :label="dict.tenantName" :value="dict.tenantId" />
          </el-select>
        </el-form-item>
        <el-form-item label="名称" prop="name">
          <el-input v-model="queryParams.name" placeholder="请输入名称" clearable />
        </el-form-item>
        <el-form-item label="关联游戏" prop="name">
          <el-select collapse-tags multiple filterable v-model="queryParams.gameIdsArr" placeholder="请选择关联游戏" clearable>
            <el-option v-for="(item,key) in gameList" :key="key" :label="item.name" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="是否显示" prop="state">
          <el-select v-model="queryParams.state" placeholder="请选择状态" clearable>
            <el-option v-for="(dict,key) in isShowOptions" :key="key" :label="dict.name" :value="key" />
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="即时通讯" prop="imCustom">
          <el-select v-model="queryParams.imCustom" placeholder="请选择状态" clearable>
            <el-option v-for="(dict,key) in IMstateOptions" :key="key" :label="dict.name" :value="key" />
          </el-select>
        </el-form-item> -->
        <el-form-item class="btns">
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button type="warning" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
          <el-button v-hasPermi="['tenant:customerService:add']" type="success" icon="el-icon-plus" @click="handleAdd">新增</el-button>

          <span style="color: #FA6400;margin-left: 15px;">
            提示: 线上客服20虞豆/天/人,128元包月,不限量
          </span>
        </el-form-item>

      </el-form>
      <!-- <div class="tip">
        <span style="font-size:18px">使用前请务必认真阅读以下事项：</span>
        <div style="color:#333">
          1、新增客服时可选择<span style="color:red;">是否启用</span>即时通讯功能。<br />
          2、客服启用即时通讯功能后，会每天扣除即时通讯使用费， <span style="color:red;font-size:18px">{{yudou}}</span> 虞豆/客服/天。<br />
          3、首次启用立即扣除<span style="color:red;">当天</span>费用，后续每天<span style="color:red;">5:00</span>扣除当天费用，虞豆不足时系统自动<span style="color:red;">停用</span>客服的即时通讯功能。<br />
          4、当<span style="color:red;">虞豆不足</span>系统停用即时通讯功能时，<span style="color:green;">充值虞豆</span>后次日5:00会<span style="color:red;">自动扣费</span>并<span style="color:green;">开启即时通讯</span>；如需立即启用即时通讯 ，可手动<span style="color:red;">点击刷新按钮</span>扣除当天费用并开启即时通讯。
        </div>
      </div> -->

      <div class="table_box">
        <el-table border stripe v-loading="loading" :data="accountList">
          <el-table-column label="客服昵称" prop="name" />
          <el-table-column label="客服类型" prop="type" show-overflow-tooltip>
            <template slot-scope="scope">
              {{getType(scope.row.type)}}
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="关联游戏" prop="gameNames" min-width="150"> </el-table-column>
          <!-- <el-table-column label="QQ" prop="qq" /> -->
          <el-table-column label="微信" prop="weixin" />
          <!-- <el-table-column label="手机号" prop="tel" /> -->
          <el-table-column label="头像" prop="qrCode">
            <template slot-scope="scope">
              <img :src="scope.row.qrCode" alt="" style="height:32px;">
            </template>
          </el-table-column>

          <el-table-column prop="workState" label="上班状态" width="100">
            <template slot-scope="scope">
              <el-switch @change="workStateChange($event,scope.row)" v-model="scope.row.workState" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="2" :disabled="!checkPermi(['tenant:customerService:edit'])"></el-switch>
            </template>
          </el-table-column>
          <el-table-column prop="replyState" label="自动回复" width="100">
            <template slot-scope="scope">
              <el-switch @change="workStateChange($event,scope.row)" v-model="scope.row.replyState" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="2" :disabled="!checkPermi(['tenant:customerService:edit'])"></el-switch>
            </template>
          </el-table-column>

          <el-table-column label="系统状态" prop="">
            <template slot-scope="scope">
              <div v-if="scope.row.imCustom==2">
                <span v-if="scope.row.imSystem==2">正常</span>
                <span v-else style="color:red">系统停用</span>
              </div>
              <span v-else>--</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="200">
            <template slot-scope="scope">
              <span style="margin-right:10px" v-if="scope.row.imCustom==2&&scope.row.imSystem==1">
                <el-button v-hasPermi="['tenant:customerService:edit']" type="add" icon="el-icon-edit" @click="refresh(scope.row)">刷新</el-button>
              </span>

              <el-button v-hasPermi="['tenant:customerService:edit']" type="edit" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
              <el-button v-hasPermi="['tenant:customerService:del']" type="del" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination :layout="'total,  prev, pager, next, jumper'" v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

      </div>
    </div>

    <!-- 添加或修改账号校验对话框 -->
    <el-dialog :title="title" @close="reset" :visible.sync="open" width="1200px" append-to-body>
      <el-form class="form-box new_form_box" ref="form" :model="form" :rules="rules" :inline="true">
        <el-form-item label="选择用户:" prop="customer">
          <virtual-select v-model="form.customer" :list="allUsers" label="nickName" value="userId" :placeholder="'输入关键字用于搜索用户'" :keeps-params="20" :is-concat="false" :concat-symbol="' || '" :is-multiple="false" :disabled="false" :size="'small'" :allow-create="false" @change="userChange" />
        </el-form-item>
        <!-- <el-form-item label="客服名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入" />
        </el-form-item> -->

        <el-form-item label="微信:" prop="weixin">
          <el-input v-model="form.weixin" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="更换头像:" prop="qrCode" class="row">
          <div class="flex" :class="{ 'hiddenupload': qrCodeList.length }">
            <el-input v-model="form.qrCode" v-show="false"></el-input>
            <el-upload class :action="uploadImgUrl" :file-list="qrCodeList" :show-file-list="true" list-type="picture-card" :limit="1" :on-success="handleAvatarSuccess" :on-remove="handleAvatarRemove" :on-preview="handlePictureCardPreview">
              <!-- <i class="el-icon-plus"></i> -->
              <div style="width: 100%;height: 100%;position: relative;">
                <img style="width: 100%;height: 100%;" src="../../../assets/img/morre.png" alt="">
                <span class="ghtx">上传头像</span>
              </div>

            </el-upload>
          </div>
        </el-form-item>
        <el-form-item label="自动回复语:" prop="replyContent" class="row">
          <span slot="label">
            <el-tooltip content="设置了自动回复后，用户首次联系该客服的时候，系统会自动回复设置的内容。" placement="top">
              <i class="el-icon-question"></i>
            </el-tooltip>
            自动回复语:
          </span>
          <el-input :rows="3" type="textarea" v-model="form.replyContent" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="自动回复图片:" prop="replyImg" class="row">
          <div class="flex" :class="{ 'hiddenupload': replyImgList.length }">
            <el-input v-model="form.replyImg" v-show="false"></el-input>
            <el-upload class :action="uploadImgUrl" :file-list="replyImgList" :show-file-list="true" list-type="picture-card" :limit="1" :on-success="handleAvatarSuccess2" :on-remove="handleAvatarRemove2" :on-preview="handlePictureCardPreview">
              <!-- <i class="el-icon-plus"></i> -->
              <div style="width: 100%;height: 100%;position: relative;">
                <img style="width:70%;margin-top:20px" src="https://imgage.maimaihao.com/yuduhulian/erp/static/icon/uploadbg.png" alt="">
                <span class="ghtx">上传图片</span>
              </div>
            </el-upload>
          </div>
        </el-form-item>
        <el-form-item label="自动回复状态:" prop="replyState">
          <el-radio-group v-model="form.replyState">
            <el-radio :label="1" :value="1">开启</el-radio>
            <el-radio :label="2" :value="2">关闭</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="客服上班状态:" prop="workState">
          <el-radio-group v-model="form.workState">
            <el-radio :label="1" :value="1">上班</el-radio>
            <el-radio :label="2" :value="2">下班</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="首页是否展示:" prop="indexShow">
          <el-radio-group v-model="form.indexShow">
            <el-radio :label="1" :value="1">展示</el-radio>
            <el-radio :label="2" :value="2">不展示</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="客服类型:" prop="typeArr" class="row">
          <!-- <el-checkbox-group v-model="form.typeArr" @change="typeChange">
            <el-checkbox v-for="(item,key) in commonMaps.kefuTypeTenantMap" :key="key" :label="key" :value="key">{{item.label}}</el-checkbox>
          </el-checkbox-group> -->
          <myCheckbox @change="typeChange" v-model="form.typeArr" :list="commonMaps.kefuTypeTenantMap" :option="{valueKey: 'index',labelKey: 'label',}"></myCheckbox>
          <div class="flex" style="width: 100%;margin-bottom: 10px;">
            <img style="width: 220px;" src="../../../assets/img/xiaoshoukefu.png" alt="">
            <img style="width: 220px;margin: 0 10px;" src="../../../assets/img/huishoukefu.png" alt="">
            <img style="width: 220px;" src="../../../assets/img/baopeikefu.png" alt="">
            <img style="width: 220px;margin-left: 10px;" src="../../../assets/img/jingpaikefu.png" alt="">

          </div>
        </el-form-item>
        <el-form-item label="关联游戏:" prop="selectGameIds" class="row">
          <div style="margin-left: 8px;">
            <myCheckbox @change="checkAllGamesChange" v-model="checkAllGames" :list="[{id:2,name:'选择全部游戏'}]"></myCheckbox>
          </div>
          <div class="addKefu">
            <myCheckbox @change="gameChange" v-model="form.selectGameIds" :list="gameList" :option="{valueKey: 'id',labelKey: 'name',}"></myCheckbox>
          </div>

        </el-form-item>
        <div style="height: 40px;"></div>
        <div class="dialog-footer">

          <el-button @click="cancel">取 消</el-button>
          <el-button type="primary" @click="submitForm">确 定</el-button>
        </div>
      </el-form>

    </el-dialog>
  </div>
</template>

<script>
import {
  listAccount,
  getAccount,
  delAccount,
  addAccount,
  updateAccount,
  exportAccount,
  consultInfogetTongJi,
  fuwubygroupKey,
} from "@/api/info/check";
import gameListApi from "@/api/gameConfig/gameList";
import supplyConfigApi from "@/api/system/supplyConfig";
import VirtualSelect from "@/components/VirtualSelect.vue";
import subtit from "@/components/indexComponents/subtit.vue";
import CountTo from "vue-count-to";
export default {
  name: "",
  components: {
    VirtualSelect,
    subtit,
    CountTo,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 账号校验表格数据
      accountList: [],
      // 弹出层标题
      title: "",
      gameList: [], //所有游戏
      userList: [],
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 4,
        createId: null,
        updateId: null,
        account: null,
        name: null,
        state: null,
        gameIdsArr: [],
      },
      isShowOptions: {
        0: {
          name: "显示",
          type: "success",
        },
        1: {
          name: "隐藏",
          type: "warning",
        },
      },
      IMstateOptions: {
        1: {
          name: "停用",
          type: "danger",
        },
        2: {
          name: "启用",
          type: "success",
        },
      },
      uploadImgUrl: "",
      qrCodeList: [],
      replyImgList: [],
      // 表单参数
      form: {
        id: null,
        createId: null,
        updateId: null,
        createTime: null,
        updateTime: null,
        account: null,
        name: null,
        state: "0",
        hxname: "",
        customer: "",
        worktype: "1",
        typeArr: [],
        selectGameIds: [],
        imCustom: "2",
        indexShow: 1,
        weixin: "",
        replyContent: "",
        replyImg: "",
      },
      selectGameNames: [],
      allUsers: [], //当前租户下所有用户
      // 表单校验
      rules: {
        customer: [
          { required: true, message: "请选择用户", trigger: "change" },
        ],
        name: [{ required: true, message: "请输入", trigger: "blur" }],
        typeArr: [{ required: true, message: "请选择", trigger: "change" }],
        selectGameIds: [
          { required: true, message: "请选择", trigger: "change" },
        ],
        imCustom: [{ required: true, message: "请选择", trigger: "change" }],
      },
      yudou: "",
      checkAllGames: [],
      tongjiData: {
        days: "",
        buyZixun: 0,
        sellZixun: 0,
        merchantZixun: 0,
        otherZixun: 0,
      },
      baoyueTime: "",
    };
  },
  computed: {
    tenantList() {
      return this.$store.getters.tenantList;
    },
    getType() {
      return (typeids) => {
        let str = "";
        if (typeids) {
          typeids.split(",").forEach((r) => {
            str += str
              ? "," + this.commonMaps.kefuTypeTenantMap[r].label
              : this.commonMaps.kefuTypeTenantMap[r].label;
          });
        }
        return str;
      };
    },
    tenantInfo() {
      return this.$store.getters.shopInfo;
    },
  },
  created() {
    this.uploadImgUrl = process.env.VUE_APP_BASE_API + "/upload/image";
    this.getList();
    this.getGameList();
    this.getAllUserList();
    this.getYudou();
    this.getZixun();
    this.getKefubaoyue();
  },
  methods: {
    // 跳转虞豆商城
    goYDSC() {
      // 跳转虞豆商城
      if (this.checkPermi(["jifenshangcheng"])) {
        this.$router.push({
          name: "Jifenshangcheng",
        });
      } else {
        this.$message.error("你还没有虞豆商城权限！");
      }
    },
    // 获取是否开通客服包月
    getKefubaoyue() {
      fuwubygroupKey({
        groupKey: "kefubaoyue",
      }).then((res) => {
        // console.log("%c Line:415 🍅 res", "color:#b03734", res);
        if (res.data) {
          this.baoyueTime = res.data.closeTime;
        }
      });
    },
    // 获取客服位虞豆
    getYudou() {
      this.getDicts("points").then((res) => {
        if (res.data && res.data.length) {
          const obj = this.arrayToObject(res.data, "dictLabel");
          this.yudou = Math.abs(obj["imCost"].dictValue);
        }
      });
    },
    // 获取咨询统计
    getZixun() {
      this.tongjiData.buyZixun = 0;
      this.tongjiData.sellZixun = 0;
      this.tongjiData.merchantZixun = 0;
      this.tongjiData.otherZixun = 0;
      consultInfogetTongJi({
        day: this.tongjiData.days || "",
      }).then((res) => {
        // console.log("%c Line:419 🥤 res", "color:#4fff4B", res);
        if (res.data && res.data.length) {
          res.data.forEach((r) => {
            if (r.business_type == 1) {
              this.tongjiData.buyZixun = r.total_count;
            } else if (r.business_type == 2) {
              this.tongjiData.sellZixun = r.total_count;
            } else if (r.business_type == 3) {
              this.tongjiData.merchantZixun = r.total_count;
            } else if (r.business_type == 99) {
              this.tongjiData.otherZixun = r.total_count;
            }
          });
        }
      });
    },
    // 获取所有用户
    getAllUserList(val) {
      supplyConfigApi
        .getAllUserList({
          userNewType: 1,
        })
        .then((res) => {
          this.allUsers = res.rows;
        });
    },
    /** 查询账号校验列表 */
    getList() {
      this.loading = true;
      listAccount(this.queryParams).then((response) => {
        this.accountList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 游戏列表
    async getGameList() {
      let res = await gameListApi.getGameList();
      res.rows.forEach((r) => {
        r.id = String(r.id);
      });
      this.gameList = res.rows;
    },

    // 取消按钮
    cancel() {
      this.open = false;
    },
    // 选择客服改变
    userChange(e) {
      this.allUsers.forEach((r) => {
        if (r.userId == e) {
          this.form.name = r.nickName;
          //   const param = {};
          // param.url = url;
          // param.name = name;
          this.qrCodeList = [
            {
              url: r.avatar,
            },
          ];
          this.form.qrCode = r.avatar;
        }
      });
    },
    // 表单重置
    reset() {
      this.form.id = null
      this.qrCodeList = [];
      this.replyImgList = [];
      this.resetForm();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 4,
        createId: null,
        updateId: null,
        account: null,
        name: null,
        state: null,
        gameIdsArr: [],
      };
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.open = true;
      this.title = "添加客服信息";
      this.qrCodeList = [];
      this.form.selectGameIds = [];
      this.selectGameNames = [];
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.form.selectGameIds = [];
      this.selectGameNames = [];
      this.qrCodeList = [];
      const id = row.id || this.ids;
      getAccount(id).then((response) => {
        this.form = { ...response.data, typeArr: [], selectGameIds: [] };
        if (this.form.qrCode) {
          this.qrCodeList = [
            {
              url: this.form.qrCode,
              name: "",
            },
          ];
        }
        if (this.form.replyImg) {
          this.replyImgList = [
            {
              url: this.form.replyImg,
              name: "",
            },
          ];
        }
        if (this.form.type) {
          this.form.typeArr = this.form.type.split(",");
        }
        if (this.form.imCustom) {
          this.form.imCustom = String(this.form.imCustom);
        } else {
          this.form.imCustom = "2";
        }
        // this.form.type = String(this.form.type)
        if (this.form.gameIds) {
          this.form.selectGameIds = this.form.gameIds.split(",");
          this.selectGameNames = this.form.gameNames.split(",");
        }
        this.open = true;
        this.title = "修改客服信息";
      });
    },
    // 选择类型改变
    typeChange(e) {
      if (this.form.typeArr && this.form.typeArr.length) {
        this.form.type = this.form.typeArr.join(",");
      } else {
        this.form.type = "";
      }
    },
    // 选择游戏改变
    gameChange(e) {
      this.form.selectGameIds;
      console.log(
        "%c Line:659 🍪 this.form.selectGameIds",
        "color:#ed9ec7",
        this.form.selectGameIds
      );
      this.selectGameNames = [];
      this.form.gameIds = this.form.selectGameIds.join(",");
      if (this.form.selectGameIds && this.form.selectGameIds.length) {
        this.gameList.forEach((game) => {
          if (this.form.selectGameIds.includes(game.id)) {
            this.selectGameNames.push(game.name);
          }
        });
      }
    },
    // 选择全部游戏
    checkAllGamesChange() {
      this.selectGameNames = [];
      this.form.gameIds = "";
      const idArr = [];
      if (this.checkAllGames && this.checkAllGames.length) {
        this.gameList.forEach((game) => {
          this.selectGameNames.push(game.name);
          idArr.push(game.id);
        });
      }
      this.form.selectGameIds = [...idArr];
      this.form.gameIds = idArr.join(",");
    },
    // 图片预览
    handlePictureCardPreview(file) {
      this.$viewerApi({
        images: [file.url],
      });
    },

    // 头像图片移除
    handleAvatarRemove(response, file) {
      this.form.qrCode = "";
      this.qrCodeList = [];
    },
    // 头像图片上传成功
    handleAvatarSuccess(res, file) {
      if (res.code == 200) {
        let url = res.data.filePath;
        let name = res.data.fileName;
        let param = {};
        param.url = url;
        param.name = name;
        this.qrCodeList.push(param);
        this.form.qrCode = res.data.filePath;
      }
    },

    // 自动回复图片移除
    handleAvatarRemove2(response, file) {
      this.form.replyImg = "";
      this.replyImgList = [];
    },
    // 自动回复图片上传成功
    handleAvatarSuccess2(res, file) {
      if (res.code == 200) {
        let url = res.data.filePath;
        let name = res.data.fileName;
        let param = {};
        param.url = url;
        param.name = name;
        this.replyImgList.push(param);
        this.form.replyImg = res.data.filePath;
      }
    },

    // 刷新系统IM状态
    refresh(row) {
      updateAccount(row).then((response) => {
        this.$modal.msgSuccess("刷新系统状态成功！");
        this.getList();
      });
    },
    // 修改上班状态
    workStateChange(e, row) {
      updateAccount(row).then((response) => {
        this.$modal.msgSuccess("修改成功");
        this.getList();
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.selectGameIds.length === 0) {
            return this.$message.error("请选择关联游戏！");
          }
          if (this.form.typeArr.length === 0) {
            return this.$message.error("请选择客服类型！");
          }
          this.form.gameIds = this.form.selectGameIds.join(",");
          this.form.gameNames = this.selectGameNames.join(",");
          this.form.type = this.form.typeArr.join(",");

          if (this.form.id != null) {
            updateAccount(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addAccount(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除id为"' + ids + '"的数据项？')
        .then(function () {
          return delAccount(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    resetForm() {
      this.$refs["form"].resetFields();
    },
  },
};
</script>
<style scoped  lang="scss">
.list-box {
  background-color: #fff;
  padding: 10px;
  border-radius: 10px;
}
.kefu-tingji-box {
  margin-bottom: 8px;

  .kefu-num-box {
    background-color: #fff;
    padding: 10px 30px;
    border-radius: 10px;
    text-align: center;
    flex-shrink: 0;
  }
  .zixun-box {
    background-color: #fff;
    padding: 10px 30px;
    border-radius: 10px;
    text-align: center;
    margin-left: 10px;
    width: 100%;
    .select {
      margin-left: 15px;
      > div {
        border: 1px solid #ccc;
        border-right: none;
        padding: 3px 10px;
        cursor: pointer;
        color: #4e5969;
        font-size: 14px;
        &:last-child {
          border-right: 1px solid #d8dce6;
          border-radius: 0 3px 3px 0;
        }
        &:first-child {
          border-radius: 3px 0 0 3px;
        }
        &.active {
          border-color: #6c5dd3;
          background: #6c5dd3;
          color: #fff;
        }
      }
    }
    .cont_box {
      flex-wrap: nowrap;
      align-items: center;
      padding-top: 15px;

      .tongji-item {
        min-width: 130px;
        // background: #ffa2c0;
        border-radius: 8px;
        // justify-content: center;
        // padding-left: 20px;
        align-items: center;
        margin-right: 20px;
        height: 120px;
        width: 25%;
        text-align: left;
        // color: #ffffff;
        // &.bjsl {
        //   background: #ffce73;
        // }
        // &.wbjsl {
        //   background: #a0d7e7;
        // }
        // &.zbsl {
        //   background: #7fba7a;
        // }
        img {
          width: 70px;
          height: 70px;
          margin-right: 15px;
        }
        .rg {
          min-width: 80px;
        }
        .tit {
          font-weight: bold;
          font-size: 16px;

          height: 30px;
          line-height: 40px;
        }
        .num {
          font-weight: 500;
          font-size: 24px;
          line-height: 40px;
        }
      }
    }
  }
}

.addKefu {
  padding-bottom: 20px;
  ::v-deep .checkbox-item {
    width: 150px;
    background: #ebeff8;
    border-radius: 4px;
    overflow: hidden;
    padding-left: 8px;
    // margin-right: 10px;
    // margin-bottom: 10px;
  }
}
::v-deep .ghtx {
  position: absolute;
  bottom: 0px;
  left: 0px;
  height: 36px;
  line-height: 36px;
  color: #6c5dd3;
  background: rgba(255, 255, 255, 0.8);
  width: 100%;
}
.dialog-footer {
  width: 100%;
  height: 60px;
  padding-top: 15px;
  background: #fff;
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 9;
}
</style>